package com.beerandjesus.sportofkings.handicapper.dao.aspect;

import com.beerandjesus.sportofkings.handicapper.dao.Database;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Annotation for specifying a database transaction boundary
 * Date: Jul 25, 2012
 * Time: 5:21:51 PM
 */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface TransactionBoundary {
    /**
     * The datasources required for this transaction
     *
     * @return The datasource
     */
    Database.Datasource[] datasources();

    /**
     * A list of exception classes that should be thrown
     * outside of transactional code if encountered within
     * transactional code.
     * <p/>
     * Note that all exceptions not listed here that are
     * encountered in transactional code will be wrapped in
     * a RuntimeException and thrown within the transaction,
     * generally resulting in a rollback.
     *
     * @return The exceptions
     */
    Class<? extends Throwable>[] expectedExceptions() default {};
}
